package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.response.ProjectCatalogResponse;
import com.nbsaas.boot.project.data.entity.ProjectCatalog;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;

/**
 * 项目分类-实体对象转化成响应对象
 */

public class ProjectCatalogResponseConvert implements Converter<ProjectCatalogResponse, ProjectCatalog> {

    @Override
    public ProjectCatalogResponse convert(ProjectCatalog source) {
        ProjectCatalogResponse result = new ProjectCatalogResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getParent() != null) {
            result.setParent(source.getParent().getId());
        }

        try {
            if (source.getParent() != null) {
                result.setParentName(source.getParent().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

